<template>
  <div style="margin:20px">
    <el-form ref="form" :model="liveObj">
      <el-form-item label="直播名称：">
        <el-input v-model="liveObj.name" style="width:60%"></el-input>
      </el-form-item>
      <el-form-item label="直播简介：">
        <el-input type="textarea" v-model="liveObj.desc" style="width:60%;"></el-input>
      </el-form-item>
      <el-form-item label="直播分类：">
        <el-select v-model="liveObj.classId" placeholder="请选择">
          <el-option v-for="item in classList" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="直播封面：">
        <el-upload
          :action="imageUploadUrl"
          :show-file-list="false"
          list-type="picture-card"
          :limit="1"
          name="avatar"
          :before-upload="handleBeforeUpload"
          :on-success="handleBannerSuccess"
          :on-remove="handleRemove"
        >
          <img
            style="width:145px;height:145px"
            v-if="liveObj.photo"
            :src="liveObj.photo"
            class="avatar"
          />
          <i v-else class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="邀约海报：">
        <el-upload
          :action="imageUploadUrl"
          :show-file-list="false"
          list-type="picture-card"
          :limit="1"
          name="avatar"
          :before-upload="handleBeforeUploadi"
          :on-success="handleBannerSuccessi"
        >
          <img
            style="width:145px;height:145px"
            v-if="liveObj.subscribePhoto"
            :src="liveObj.subscribePhoto"
            class="avatar"
          />
          <i v-else class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>

      <el-form-item label="客服二维码：">
        <el-upload
          :action="imageUploadUrl"
          :show-file-list="false"
          list-type="picture-card"
          :limit="1"
          name="avatar"
          :before-upload="handleBeforeUploadie"
          :on-success="handleBannerSuccessie"
        >
          <img
            style="width:145px;height:145px"
            v-if="liveObj.service"
            :src="liveObj.service"
            class="avatar"
          />
          <i v-else class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>

      <el-form-item label="邀请话术：">
        <el-input v-model="liveObj.subscribeWord" style="width:60%"></el-input>
      </el-form-item>
      <el-form-item label="轮播公告：">
        <el-input v-model="liveObj.swiperNotice" style="width:60%"></el-input>
      </el-form-item>
      <el-form-item label="直播公告：">
        <el-input
          type="textarea"
          :rows="6"
          v-model="liveObj.liveNotice"
          placeholder="直播未开始时的提示语"
          style="width:60%"
        ></el-input>
      </el-form-item>
      <el-form-item label="直播时间：">
        <el-date-picker
          v-model="liveObj.startTime"
          type="datetime"
          placeholder="选择开始日期时间"
          @change="selectDate($event,1)"
        ></el-date-picker>
        <el-date-picker
          v-model="liveObj.endTime"
          type="datetime"
          placeholder="选择结束日期时间"
          @change="selectDate($event,2)"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="管理员：">
        <el-button @click="showUser = true,JGmanage = {},userList=[]">添加管理员</el-button>
        <span v-if="JGmanage.userName">管理员：{{JGmanage.userName}}</span>
      </el-form-item>
      <el-form-item label="老师：">
        <el-button @click="showTeacher = true,JGTeacher ={},userList=[]">添加老师</el-button>
        <span v-if="JGTeacher.name">老师：{{JGTeacher.name}}</span>
      </el-form-item>

      <!-- <el-form-item label="老师简介：">
        <el-input type="textarea" v-model="liveObj.teacherDesc" style="width:60%;"></el-input>
      </el-form-item>-->
      <el-form-item label="直播详情：">
        <span>&nbsp;</span>
        <tinymce :height="300" v-model="liveObj.particulars" style="width: 705px;"></tinymce>
      </el-form-item>
      <el-form-item label="交流群详情：">
        <span>&nbsp;</span>
        <tinymce :height="300" v-model="liveObj.communicGroup" style="width: 705px;"></tinymce>
      </el-form-item>
      <el-form-item label="售卖方式：">
        <el-radio v-model="liveObj.type" :label="1">免费</el-radio>
        <el-radio v-model="liveObj.type" :label="2">付费</el-radio>
        <el-radio v-model="liveObj.type" :label="3">加密</el-radio>
      </el-form-item>
      <el-form-item label="价格：" v-if="liveObj.type == 2">
        <el-input v-model="liveObj.price" style="width:80px"></el-input>元
      </el-form-item>
      <el-form-item label="原价：" v-if="liveObj.type == 2">
        <el-input v-model="liveObj.originalPrice" style="width:80px"></el-input>元
      </el-form-item>
      <el-form-item label="针对人员免费设置：" v-if="liveObj.type == 2">
        <el-checkbox label="针对VIP免费" v-model="freePeopel.vip"></el-checkbox>
        <el-checkbox label="针对合伙人免费" v-model="freePeopel.partner" name="type"></el-checkbox>
        <el-checkbox label="针对运营中心免费" v-model="freePeopel.center" name="type"></el-checkbox>
        <el-checkbox label="针对员工免费" v-model="freePeopel.staff" name="type"></el-checkbox>
      </el-form-item>
      <el-form-item label="密码：" v-if="liveObj.type == 3">
        <el-input v-model="liveObj.pwd" style="width:150px"></el-input>
      </el-form-item>
      <el-form-item label="是否选择活动：">
        <el-radio v-model="showActive" :label="1">是</el-radio>
        <el-radio v-model="showActive" :label="0">否</el-radio>

        <div v-if="showActive == 1">
          <el-radio
            v-for="(item,index) in activeArray"
            :key="index"
            v-model="liveObj.activityId"
            :label="index+1"
          >{{item}}</el-radio>
          <div v-if="liveObj.activityId">
            <span>
              邀请
              <font v-if="liveObj.activityId == 2">每</font>
            </span>
            <el-input-number
              v-if="liveObj.activityId == 1 || liveObj.activityId == 3"
              v-model="liveObj.condition"
              controls-position="right"
              style="width:100px"
            ></el-input-number>
            <span>
              人可获得
              <font v-if="liveObj.activityId">（{{activeArray[liveObj.activityId-1]}}）</font>
            </span>
            <span v-if="liveObj.activityId == 2">
              <el-input-number
                v-model="liveObj.Oblance"
                controls-position="right"
                style="width:100px"
              ></el-input-number>个
            </span>
          </div>
        </div>
      </el-form-item>

      <el-form-item label="报名填写信息：">
        <el-checkbox label="公司" v-model="message.company" name="type"></el-checkbox>
        <el-checkbox label="职位" v-model="message.job" name="type"></el-checkbox>
      </el-form-item>

      <el-form-item label="参与人数基数：">
        <el-input-number v-model="liveObj.number" placeholder="请输入参与人数基数" controls-position="right"></el-input-number>&nbsp;人
      </el-form-item>
      <el-form-item label="预约人数基数：">
        <el-input-number
          v-model="liveObj.subscribeNumber"
          placeholder="请输入预约人数基数"
          controls-position="right"
        ></el-input-number>&nbsp;人
      </el-form-item>

      <h2>关联商品：</h2>
      <el-form-item label="商品：">
        <el-button @click="showGoodWindow = true,selectGoods()">选择商品</el-button>
      </el-form-item>

      <el-table
        v-if="liveObj.prod.length >0"
        :data="liveObj.prod"
        style="width: 500px;margin-bottom:20px"
      >
        <el-table-column prop="name" label="名称" width="180"></el-table-column>
        <el-table-column label="类型" width="180">
          <template slot-scope="scope">
            <div style="display:flex;align-items:center">
              <p>{{ scope.row.prodType == 1 ?'课程' :scope.row.prodType == 2 ?'线下活动' :'商品' }}</p>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="deleteGoods(scope.row)">取消关联</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- <el-form-item label="代理商定金：">
        <el-input-number
          v-model="liveObj.partnerPrice"
          placeholder="请输入定金金额"
          controls-position="right"
        ></el-input-number>&nbsp;元
      </el-form-item>
      <el-form-item label="VIP：">
        <el-input-number v-model="liveObj.vipPrice" placeholder="请输入定金金额" controls-position="right"></el-input-number>&nbsp;元
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="creatLive()">保存</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>

    <el-dialog title="请选择管理员" :visible.sync="showUser" width="40%">
      <el-input
        placeholder="请输入姓名手机号进行搜索"
        v-model="managerName"
        @keyup.enter="addManage"
        style="width:70%"
      ></el-input>
      <el-button type="primary" icon="el-icon-search" size="small" @click="addManage()">搜索</el-button>
      <el-table
        ref="multipleTable"
        :data="userList"
        tooltip-effect="dark"
        height="300"
        style="width: 100%;"
      >
        <el-table-column label="名称">
          <div style="display:flex" slot-scope="scope">
            <img style="width:50px;height:50px" :src="scope.row.avatar" alt />
            <div>
              <span>用户名：{{scope.row.userName}}</span>
              <p>手机号：{{scope.row.mobile}}</p>
            </div>
          </div>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button @click="selectUser(scope.row)">选择</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog title="请选择讲师" :visible.sync="showTeacher" width="40%">
      <el-input
        placeholder="请输入姓名进行搜索"
        v-model="teacherName"
        @keyup.enter="addTearcher"
        style="width:70%"
      ></el-input>
      <el-button type="primary" icon="el-icon-search" size="small" @click="addTearcher()">搜索</el-button>
      <el-table
        ref="multipleTable"
        :data="userList"
        tooltip-effect="dark"
        height="300"
        style="width: 100%;"
      >
        <el-table-column label="名称">
          <div style="display:flex" slot-scope="scope">
            <img style="width:50px;height:50px" :src="scope.row.avatar" alt />
            <div>
              <span>用户名：{{scope.row.name}}</span>
            </div>
          </div>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button @click="selectTeacher(scope.row)">选择</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <el-dialog title="请选择课程/线下活动/商品" :visible.sync="showGoodWindow" width="60%">
      <el-tabs v-model="goodsType" @tab-click="selectGoods">
        <el-input style="width:70%" v-model="listQuery.name"></el-input>
        <el-button type="primary" @click="selectGoods">搜索</el-button>
        <el-tab-pane label="课程" name="course">
          <el-table
            v-loading="listLoading"
            ref="multipleTable"
            :data="goodsArray"
            tooltip-effect="dark"
            height="500"
            @selection-change="handleSelectionChange"
            style="width: 100%"
          >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column label="名称">
              <template slot-scope="scope">
                <div style="display:flex;align-items:center">
                  <img width="90" height="60" :src="scope.row.courseAvatar" alt />
                  <div style="padding-left:10px">
                    <p>名称：{{ scope.row.name }}</p>
                    <p>价格：￥{{ scope.row.price }}</p>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="lecturerName" label="讲师"></el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="线下活动" name="active">
          <el-table
            v-loading="listLoading"
            ref="multipleTable"
            height="500"
            :data="goodsArray"
            tooltip-effect="dark"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column label="名称">
              <template slot-scope="scope">
                <div style="display:flex;align-items:center">
                  <img width="90" height="60" :src="scope.row.poster" alt />
                  <p style="padding-left:10px">名称：{{ scope.row.name }}</p>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="enrollStatus" label="状态"></el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="商品" name="goods">
          <el-table
            height="500"
            v-loading="listLoading"
            ref="multipleTable"
            :data="goodsArray"
            tooltip-effect="dark"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column label="名称">
              <template slot-scope="scope">
                <div style="display:flex;align-items:center">
                  <img width="90" height="60" :src="scope.row.avatar" alt />
                  <p style="padding-left:10px">名称：{{ scope.row.name }}</p>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="price" label="价格："></el-table-column>
          </el-table>
        </el-tab-pane>
        <!-- <el-pagination
          style="margin-top:20px"
          background
          @current-change="handleCurrentChange"
          :current-page.sync="listQuery.page"
          :page-size="listQuery.limit"
          layout="total, prev, pager, next, jumper"
          :total="Number(goodsTotal)"
        ></el-pagination>-->
        <el-button
          style="position:absolute;bottom:0px;right:0"
          @click="confirmGoods"
          type="primary"
        >确定</el-button>
      </el-tabs>
    </el-dialog>
  </div>
</template>
<script>
import {
  createLive,
  getMemberList,
  LiveList,
  saveCommodity
} from "@/api/member";
import {
  saveSocialRoom,
  getManager,
  saveLecturer,
  classList
} from "@/api/social";
import { getActivities } from "@/api/activities";
import { getCourseList } from "@/api/course";
import { toGetList } from "@/api/column";
import { getLecturerList } from "@/api/lecturer";
import { getGoodsList } from "@/api/goods";
import Tinymce from "@/components/Tinymce";
export default {
  data() {
    return {
      listLoading: true,
      showGoodWindow: false,
      freePeopel: {
        vip: false,
        partner: false,
        center: false,
        staff: false
      },
      message: {
        company: false,
        job: false
      },
      showActive: 0,
      isActive: "",
      liveObj: {
        name: "",
        message: "",
        desc: "",
        photo: "",
        startTime: "",
        type: "",
        pwd: "",
        price: "",
        prod: [],
        particulars: "",
        manage: "",
        // partnerPrice: null,
        activityId: "",
        condition: null,
        Oblance: null,
        teacherId: null,
        classId: null,
        communicGroup: "",
        number: "",
        subscribeNumber: "",
        subscribePhoto: "",
        subscribeWord: "",
        swiperNotice: "",
        liveNotice: "",
        service: "",
        vip: [{ price: "688", title: "VIP", detail: "" }],
        partner: [{ price: "500", title: "招商加盟", detail: "" }]
        // vipPrice: ""
      },
      activeArray: ["线下礼物", "赠送欧币", "免费观看"],
      imageUploadUrl: process.env.BASE_API + "/common/live/imageUpload",
      radio: 1,
      userList: [],
      JGmanage: {},
      showUser: false,
      managerName: "",
      managerNone: "",
      showColumn: false,
      showTeacher: false,
      teacherName: "",
      JGTeacher: {},
      classList: [],
      goodsType: "course",
      listQuery: {
        page: 1,
        limit: 10000,
        endAt: "",
        startAt: "",
        status: "",
        name: "",
        currentPage: 1
      },
      goodsTotal: "",
      goodsArray: [],
      tmpCourse: [],
      tmpActiviey: [],
      tmpGoods: []
    };
  },
  watch: {},
  created() {
    // var lett = this;
    // document.onkeydown = function(e) {
    //   var key = window.event.keyCode;
    //   if (key == 13) {
    //     lett.addManage();
    //   }
    // };
  },
  methods: {
    deleteGoods(item) {
      for (let i = 0; i < this.liveObj.prod.length; i++) {
        const element = this.liveObj.prod[i].name;
        if (element == item.name) {
          this.liveObj.prod.splice(i, 1);
        }
      }
    },
    confirmGoods() {
      for (let i = 0; i < this.tmpCourse.length; i++) {
        this.tmpCourse[i].prodType = 1;
      }
      for (let i = 0; i < this.tmpActiviey.length; i++) {
        this.tmpActiviey[i].prodType = 2;
      }
      for (let i = 0; i < this.tmpGoods.length; i++) {
        this.tmpGoods[i].prodType = 3;
      }
      var tmpArr = this.tmpCourse.concat(this.tmpActiviey);
      this.liveObj.prod = tmpArr.concat(this.tmpGoods);
      this.showGoodWindow = false;
    },
    handleSelectionChange(val) {
      // prodType: 1课程 2线下活动 3商品
      if (this.goodsType == "course") {
        this.tmpCourse = val;
      } else if (this.goodsType == "active") {
        this.tmpActiviey = val;
      } else if (this.goodsType == "goods") {
        this.tmpGoods = val;
      }
    },
    selectGoods() {
      this.listQuery.status = "";
      if (this.goodsType == "course") {
        this.getCourseData();
      } else if (this.goodsType == "active") {
        this.listQuery.status = -1;
        this.getActiveData();
      } else if (this.goodsType == "goods") {
        this.getGoodsData();
      }
    },
    getActiveData() {
      this.listLoading = true;
      getActivities(this.listQuery).then(res => {
        this.goodsArray = res.data.data.data;
        this.goodsTotal = res.data.data.total;
        this.listLoading = false;
      });
    },
    getGoodsData() {
      this.listLoading = true;
      getGoodsList(this.listQuery).then(res => {
        this.goodsArray = res.data.data.list.data;
        this.goodsTotal = res.data.data.list.total;
        this.listLoading = false;
      });
    },
    getCourseData() {
      this.listLoading = true;
      getCourseList(this.listQuery).then(res => {
        this.goodsArray = res.data.data.list.data;
        this.goodsTotal = res.data.data.list.total;
        this.listLoading = false;
      });
    },
    selectTeacher(val) {
      this.teacherName = val.name;
      this.JGTeacher = val;

      this.liveObj.teacherId = val.userId;
      this.showTeacher = false;
    },
    selectUser(val) {
      this.liveObj.manage = val.userId;
      this.JGmanage = val;
      this.managerName = val.userName;
      this.showUser = false;
    },
    addTearcher() {
      this.userList = [];

      getLecturerList({ name: this.teacherName }).then(res => {
        this.userList = res.data.data.data;
      });
    },
    addManage() {
      this.userList = [];

      getManager({ userName: this.managerName }).then(res => {
        this.userList = res.data.data;
      });
      this.showUser = true;
    },

    // 添加课程
    creatLive() {
      var free = [];

      if (this.freePeopel.vip) {
        free.push(1);
      }
      if (this.freePeopel.partner) {
        free.push(2);
      }
      if (this.freePeopel.center) {
        free.push(3);
      }
      if (this.freePeopel.staff) {
        free.push(4);
      }
      console.log(free.toString());
      this.liveObj.FreePeople = free.toString();

      var message = [];
      if (this.message.company) {
        message.push(1);
      }
      if (this.message.job) {
        message.push(2);
      }
      this.liveObj.message = message.toString();
      // return;
      // var prod = this.goodsSubmit.concat(this.courseSubmit);
      // this.liveObj.prod = prod.concat(this.columnSubmit);
      console.log(this.liveObj);
      if (this.liveObj.name == "") {
        this.$message.warning("请填写直播名称");
        return;
      } else if (this.liveObj.desc == "") {
        this.$message.warning("请填写直播简介");
        return;
      } else if (this.liveObj.photo == "") {
        this.$message.warning("请填加直播图片");
        return;
      } else if (this.liveObj.startTime == "") {
        this.$message.warning("请填写直播开始时间");
        return;
      } else if (this.liveObj.classId == "" || this.liveObj.classId == null) {
        this.$message.warning("请填写直播分类");
        return;
      } else if (this.liveObj.teacherId == "") {
        this.$message.warning("请填写直播讲师");
        return;
      } else if (this.liveObj.manage == "") {
        this.$message.warning("请填写直播管理员");
        return;
      }
      // else if (this.liveObj.teacherDesc == "") {
      //   this.$message.warning("请填写老师简介");
      //   return;
      // }
      else if (this.liveObj.particulars == "") {
        this.$message.warning("请填写课程详情");
        return;
      } else if (this.liveObj.type == "") {
        this.$message.warning("请填写售卖方式");
        return;
      } else if (this.liveObj.type == 2 && this.liveObj.price == "") {
        this.$message.warning("请填写直播间价格");
        return;
      } else if (this.liveObj.type == 3 && this.liveObj.pwd == "") {
        this.$message.warning("请填写直播间密码");
        return;
      }
      if (this.$route.query.edite) {
        this.liveObj.liveId = JSON.parse(
          localStorage.getItem("liveInfo")
        ).liveId;
      }
      createLive(this.liveObj).then(res => {
        // if (!this.$route.query.edite) {
        let liveId = res.data.data;
        // saveCommodity({
        //   vip: [{ price: "", title: "", detail: "" }],
        //   partner: [{ price: "", title: "", detail: "" }],
        //   liveId: liveId
        // }).then(res => {});
        saveSocialRoom({
          name: this.liveObj.name,
          liveId: liveId,
          intro: this.liveObj.desc,
          manager: this.JGmanage,
          avatar: this.liveObj.photo,
          price: null,
          teacherId: this.JGTeacher,
          // manager: this.managerNone,
          isFree: 0,
          hasTeacher: -1,
          lecturerUserId: 0
        }).then(res => {
          this.$message.success(res.data.data.message);
        });
        this.$router.push({
          name: "liveList"
        });
        // }
      });
    },
    //选择时间
    selectDate(val, type) {
      var mounth = String(val).substring(4, 7);
      var day = String(val).substring(8, 10);
      var year = String(val).substring(11, 15);
      var time = String(val).substring(16, 25);
      console.log(day);
      console.log(year);
      console.log(time);
      if (mounth == "Jan") {
        mounth = 1;
      } else if (mounth == "Feb") {
        mounth = 2;
      } else if (mounth == "Mar") {
        mounth = 3;
      } else if (mounth == "Apr") {
        mounth = 4;
      } else if (mounth == "May") {
        mounth = 5;
      } else if (mounth == "Jun") {
        mounth = 6;
      } else if (mounth == "Jul") {
        mounth = 7;
      } else if (mounth == "Aug") {
        mounth = 8;
      } else if (mounth == "Sep") {
        mounth = 9;
      } else if (mounth == "Oct") {
        mounth = 10;
      } else if (mounth == "Nov") {
        mounth = 11;
      } else if (mounth == "Dec") {
        mounth = 12;
      }
      if (type == 1) {
        this.liveObj.startTime = `${year}-${mounth}-${day} ${time}`;
      } else if (type == 2) {
        this.liveObj.endTime = `${year}-${mounth}-${day} ${time}`;
      }
      console.log(this.liveObj.startTime);
    },
    // 保存图片路径
    handleBannerSuccess(val) {
      console.log(val);
      this.liveObj.photo = val.data.imageUrl;
    },
    handleBannerSuccessi(val) {
      console.log(val);
      this.liveObj.subscribePhoto = val.data.imageUrl;
    },
    handleBeforeUploadie(file) {
      console.log("上传文件之前触发啊、。。。");
      const isImg =
        file.type == "image/jpeg" ||
        file.type == "image/png" ||
        file.type == "image/gif";
      if (!isImg) {
        this.$message.warning("上传图片只能是 JPG 或 PNG 格式");
      }
      const isLt3M = file.size / 1024 / 1024 < 3;
      if (!isLt3M) {
        this.$message.error("上传图片大小不能超过 3MB!");
      }
      return isImg && isLt3M;
    },
    handleBannerSuccessie(val) {
      console.log(val);

      this.liveObj.service = val.data.imageUrl;
    },
    handleRemove(val) {
      console.log(val);
    },
    handleBeforeUpload(file) {
      console.log("上传文件之前触发啊、。。。");
      const isImg =
        file.type == "image/jpeg" ||
        file.type == "image/png" ||
        file.type == "image/gif";
      if (!isImg) {
        this.$message.warning("上传图片只能是 JPG 或 PNG 格式");
      }
      const isLt3M = file.size / 1024 / 1024 < 3;
      if (!isLt3M) {
        this.$message.error("上传图片大小不能超过 3MB!");
      }
      return isImg && isLt3M;
    },
    handleBeforeUploadi(file) {
      console.log("上传文件之前触发啊、。。。");
      const isImg =
        file.type == "image/jpeg" ||
        file.type == "image/png" ||
        file.type == "image/gif";
      if (!isImg) {
        this.$message.warning("上传图片只能是 JPG 或 PNG 格式");
      }
      const isLt3M = file.size / 1024 / 1024 < 3;
      if (!isLt3M) {
        this.$message.error("上传图片大小不能超过 3MB!");
      }
      return isImg && isLt3M;
    },
    getClass() {
      classList().then(res => {
        this.classList = res.data.data;
      });
    },
    getLiveData() {
      LiveList({ type: 1, liveId: this.$route.query.liveId }).then(res => {
        this.liveObj = res.data.data;
        if (this.liveObj.message) {
          if (this.liveObj.message.includes("1")) {
            this.message.company = true;
          }
          if (this.liveObj.message.includes("2")) {
            this.message.job = true;
          }
        }
        if (this.liveObj.activityId !== 0) {
          this.showActive = 1;
        }
        this.JGmanage = this.liveObj.manages[0];
        this.JGTeacher = this.liveObj.teachers;
        delete this.liveObj.manages;
        delete this.liveObj.teachers;
      });
    }
  },
  mounted() {
    this.getClass();
    if (this.$route.query.edite) {
      this.getLiveData();
    }
  },
  components: {
    Tinymce
  }
};
</script>
<style scoped>
</style>
